<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="css/zhuce.css">
</head>

<body>
    <div id="box">
        <div class="box-con">
            <div class="title">
                <span>Mercedes me Id</span>
            </div>
            <div class="one-title">
                <div class="left">
                    <span>
                        <a href="submit.html">登录</a>
                    </span>
                </div>
                <div class="right">
                    <span>
                        <a href="zhuce.html">注册</a>
                    </span>
                </div>
            </div>
            <div class="two-title">
                <div class="box1">
                    <input type="text" placeholder="账号" id="username">
                </div>
                <div class="box2">
                    <input type="text" placeholder="密码" id="password">
                </div>
                <div class="box3" id="btn">确定</div>
                <div class="box4">
                    创建您的Mercedes me ID
                </div>
                <div class="box5">
                    <div class="weixin"></div>
                    <div class="qq"></div>
                    <div class="weibo"></div>
                </div>

            </div>
        </div>
    </div>
    <script src="js/jquery.min.js"></script>
    <script>
        $("#btn").click(function () {
            $.ajax({
                url: "http://127.0.0.1/bc/submit.php",
                method: "post",
                data: {
                    username: $("#username").val(),
                    userPass: $("#password").val(),
                },
                success(data) {
                    if (data === "success") {
                        alert("登录成功");
                        // console.log(data)
                        sessionStorage.setItem("userinfor", $("#username").val());
                        sessionStorage.setItem("password", $("#password").val())
                        location.href="index.html"
                    }
                    else {
                        alert("登录失败")
                    }
                }
            })
        })
    // $("#btn").click(function(){
    //   let http = new XMLHttpRequest()
    //   http.open("get",`http://127.0.0.1:8080/submit?username=${$("#username").val()}&password=${$("#password").val()}`)
    //   http.send()
    //   http.onreadystatechange = function(){
    //       if(http.readyState === 4){
    //           // if(http.responseText === "success"){
    // //   alert("登录成功")
    // //   location.href = "http://10.35.161.20/27.01/作业/oA.html"
    //           // }
    //           // else{
    //           // 	alert("用户名或密码错误")
    // // }
    // if(http.responseText==="error"){
    //   alert("用户名或密码错误")
    // }
    // if(http.responseText==="success"){
    // //   sessionStorage.setItem("isLogin","1")
    //   alert("登录成功");
    // //    location.href = "https://www.mercedes-benz.com.cn/"
    // }
    //       }
    //   }

    // })


    </script>
</body>

</html>